
[m,n]=size(xbin);
x2=ones(m,n);
for j=1:n
    cont=0;
    a=1;
    for i=1:m
       if xbin(i,j)== 0
           cont=cont+a; 
           a=a+1;
        end
    end
    if (m-cont)<=0
        cont=m-1;
    end
    x2(m-cont:m,j)=0;
end
figure;
imshow(x2);